/*--------------------------------------------------------------------------*/
/*--------------------------------------------------------------------------*/
// pscreen.hpp - Abstract PegScreen class definition.
//
// Author: Kenneth G. Maxwell
//
// Copyright (c) 1997-2003 Swell Software
//              All Rights Reserved.
//
// Unauthorized redistribution of this source code, in whole or part,
// without the express written permission of Swell Software
// is strictly prohibited.
//
// Notes:
//
// This class defines all of the methods which must be supported in
// instantiated screen classes. Users may of course add additional members
// in custom derived classes, but only those members found here will be used
// by PEG.
/*--------------------------------------------------------------------------*/
/*--------------------------------------------------------------------------*/

#ifndef _PEGSCREEN_
#define _PEGSCREEN_

/*--------------------------------------------------------------------------*/
// Pointer Types:

#define PPT_NORMAL              0
#define PPT_VSIZE               1
#define PPT_HSIZE               2
#define PPT_NWSE_SIZE           3
#define PPT_NESW_SIZE           4
#define PPT_IBEAM               5
#define PPT_HAND                6

#define SYSTEM_POINTER_TYPES    7

#define NUM_POINTER_TYPES (SYSTEM_POINTER_TYPES + PEG_USER_PTR_TYPES)


#define MAX_DRAW_SURFACE        50

/*--------------------------------------------------------------------------*/
/*--------------------------------------------------------------------------*/
struct PegPointer
{
    PegBitmap *Bitmap;
    PEGINT xOffset;
    PEGINT yOffset;
};

/*--------------------------------------------------------------------------*/
/*--------------------------------------------------------------------------*/
// forward reference
struct Viewport;


/*--------------------------------------------------------------------------*/
/*--------------------------------------------------------------------------*/
struct DrawSurface
{
    PegBitmap *pMap;
    PEGINT Id;
    PEGINT Alpha;
    PEGUINT Type;
    PEGINT DrawCount;
    PEGINT HardwareLayer;
    PEGULONG HardwareParam;

    PEGINT DrawOffsetX;
    PEGINT DrawOffsetY;
    PEGINT DisplayOffsetX;
    PEGINT DisplayOffsetY;

    PegRect Invalid;
    PEGCOLOR **pScanPointers;
    PegThing *pNotify;
    DrawSurface *pNext;
    DrawSurface *pPrev;


   #if defined(PEG_VIEWPORTS)
    // default viewport for unmanaged draw surfaces
    Viewport *pView;
   #endif

   #if defined(PEG_OPENGL_MULTIPLE_SURFACES)
    PEGINT RequestedWidth;
    PEGINT RequestedHeight;
   #endif // PEG_OPENGL_MULTIPLE_SURFACES
};

/*--------------------------------------------------------------------------*/
/*--------------------------------------------------------------------------*/
struct DrawContext
{
   #ifdef PEG_VIEWPORTS
    // init by BeginDraw
    Viewport *pViewportList;
   #endif

    // init by BeginDraw
    PEGCOLOR **pScanPointers;

   #if (PEG_ORIENTATION != PEG_ORIENTATION_NATIVE)
    PEGINT   xDrawOffset;
   #else
    PEGINT   yDrawOffset;
   #endif

    // init by BeginDraw
    PegRect  Clip;
    DrawSurface *pSurface;
};

#define PEG_DST_SIMPLE      0x0000      // surface is simple off-screen bitmap
#define PEG_DST_HARDWARE    0x0001      // surface is linked to hardware layer
#define PEG_DST_VISIBLE     0x0002      // managed surface is visible
#define PEG_DST_OVERLAY     0x0004      // managed surface is overlay on background
#define PEG_DST_MANAGED     0x0008      // surface is auto-overlay and clipped
#define PEG_DST_CLIPPED     0x0010      // simple surface is clipped
#define PEG_DST_ALPHA_CHAN  0x0020      // surface has alpha channel


#if (PEG_ORIENTATION != PEG_ORIENTATION_NATIVE)
  #define SCANLINESTART(_Line_) \
     (mpContext->pScanPointers[_Line_ - mpContext->xDrawOffset])
#else
  #define SCANLINESTART(_Line_) \
     (mpContext->pScanPointers[_Line_ - mpContext->yDrawOffset])
#endif



/*--------------------------------------------------------------------------*/
/*--------------------------------------------------------------------------*/
struct RGB_VAL
{
    PEGUBYTE Red;
    PEGUBYTE Green;
    PEGUBYTE Blue;
    RGB_VAL(PEGUBYTE a, PEGUBYTE b, PEGUBYTE c) {Red = a; Green = b; Blue = c;}
    RGB_VAL() {Red = Green = Blue = 0;}
    RGB_VAL operator += (RGB_VAL r)
    {
        Red = (PEGUBYTE) (Red + r.Red);
        Green = (PEGUBYTE) (Green + r.Green);
        Blue = (PEGUBYTE) (Blue + r.Blue);
        return *this;
    }
};

#if defined(PEG_VID_MEM_MANAGER)
#include "pegheap.hpp"
#endif

/*--------------------------------------------------------------------------*/
// Some screen drivers use a different output color width than the
// basic PEGCOLOR type. This is an override mechanism, normally turned off.
/*--------------------------------------------------------------------------*/

//#define USE_PEGULONG_SCANPTR
//#define USE_PEGUSHORT_SCANPTR

/*--------------------------------------------------------------------------*/
// There are different mouse drawing modes. Define which we are using
//
// 1) PEG_HARWARE_CURSOR    // mouse drawing is hardware supported
// 2) PEG_SOFTWARE_CURSOR   // mouse drawing is done in software
//
// 3) PEG_CURSOR_LAYER      // their is a unique drawing layer for the mouse.
//                          // this may be a hardware or software layer.
//
// PEG_HARDWARE_CURSOR is defined (or not) in pconfig.hpp.
// if HARDWARE_CURSOR is not defined and their is mouse support,
// we define SOFTWARE_CURSOR (it has to be drawn somewhere!).
//
//
/*--------------------------------------------------------------------------*/

#if defined(PEG_MOUSE_SUPPORT)

#define MOUSE_SURFACE_SIZE 32       // 32x32 mouse pointer surface

#if defined(PEG_HARDWARE_CURSOR)

#define PEG_CURSOR_LAYER            // always a layer for hardware mouse

#else

#define PEG_SOFTWARE_CURSOR

#if defined(PEG_MULT_SOFT_SURFACES)
#define PEG_CURSOR_LAYER            // use a layer if multi-layered software mouse
#endif

#endif      // HARDWARE_CURSOR?
#endif      // mouse support?

PEGINT PegSqRoot(PEGLONG x);

/*--------------------------------------------------------------------------*/
// This is the abstract screen class definition that all Peg object are
// coded to. Note that this is an abstract class. An instantiable screen
// class must be defined for a working library.
/*--------------------------------------------------------------------------*/

class PegScreen
{
    private:

    public:
        PegScreen(const PegRect &);
        virtual ~PegScreen();

        PEGUBYTE AddPointerType(PegBitmap *pMap, PEGINT XOffset,
                                PEGINT YOffset);

       #ifdef PEG_ARC_GRAPHICS
        virtual void Arc(PEGINT xc, PEGINT yc, PEGINT XRadius, PEGINT YRadius,
                         PEGINT start_angle, PEGINT end_angle, PegBrush &Brush,
                         PEGINT width = 1);
       #endif

        virtual PEGINT BeginDraw(PegThing *Caller, const PegRect &Invalid,
            PEGINT Surface);

       #if defined(PEG_PRINTER_SUPPORT)
        virtual void BeginPrint(void);
       #endif

        void Bitmap(PegPoint Where, PegBitmap *pMap);

        void BitmapFill(PegRect &Rect, PegBitmap *pMap);

        void BitmapOverlay(PegThing *pCaller, PegRect Rect, PegBitmap *pMap);

       #if defined(PEG_IMAGE_SCALING) && defined(PEG_OPERA)
        virtual void BitmapScale(PegBitmap *pMap, PegRect pDest);
       #endif

       #ifdef PEG_OPERA
        virtual void BitmapWithPalette(PegRect Where,
                                       PegBitmap *pMap, const PEGUBYTE *pPal,
                                       PEGINT PalSize, PEGBOOL OnTop = FALSE);
       #endif

        virtual void Capture(PegCapture *Info, PegRect &Rect) = 0;

       #ifdef PEG_ARC_GRAPHICS
        virtual void Chord(PegRect &Bound, PegPoint p1,
                           PegPoint p2, PegBrush &Brush);

        virtual void Circle(PEGINT xCenter, PEGINT yCenter,
                            PEGINT r, PegBrush &Brush);
       #endif

        PEGBOOL ClipRect(PegRect &Rect);

        virtual PegBitmap *CreateBitmap(PEGINT Width, PEGINT Height,
            PEGINT Style = BMF_RAW|BMF_HAS_TRANS);

        virtual PEGINT CreateDrawSurface(PEGINT Type,
            PEGINT Width, PEGINT Height, PEGINT xOffset, PEGINT yOffset,
            PEGINT HardLayer = -1, PegThing *pNotify = NULL);

       #ifdef PEG_VECTOR_FONTS
        virtual void DeleteFont(PegFont *pFont);
       #endif

        void DestroyBitmap(PegBitmap *pMap);
        virtual void DestroyDrawSurface(PEGINT Surface);

        PEGUINT DrawNesting(void) {return mDrawNesting;}

        virtual void DrawAliasMap(PegPoint Where, const PegBitmap *pMap,
            PegBrush &Brush);

        void DrawLineEnds(PEGINT XStart, PEGINT YStart, PEGINT XEnd,
                          PEGINT YEnd, PegBrush &Brush);
        void DrawRotatedText(PegPoint Center, PEGINT iAngle,
            const PEGCHAR *pText, const PegFont *Font, PegBrush &Brush);

        virtual void DrawText(PegPoint Where,
                              const PEGCHAR *Text, PegBrush &Brush,
                              const PegFont *Font, PEGINT Count = -1);

       #ifdef PEG_BITMAP_WRITER
        PEGUBYTE *DumpWindowsBitmap(PEGULONG *pPutSize, PegRect &View);
       #endif

       #ifdef PEG_ARC_GRAPHICS
        virtual void Ellipse(const PegRect &Bound, PegBrush &Brush);
       #endif

        virtual void EndDraw();

       #if defined(PEG_PRINTER_SUPPORT)
        virtual void EndPrint(void);
       #endif   // PEG_PRINTER_SUPPORT

        DrawSurface *FindSurface(PEGINT SurfaceId);

       #ifdef PEG_IMAGE_SCALING
        virtual PEGCOLOR GetBitmapPixel(PEGINT x, PEGINT y,
                                        PegBitmap *pMap) = 0;
       #endif

        virtual PEGUBYTE *GetPalette(PEGULONG *pPutSize) = 0;
        virtual PEGCOLOR GetPixel(PEGINT x, PEGINT y);

       #if defined(PEG_MOUSE_SUPPORT)
        PegBitmap *GetPointer(void) {return mpCurPointer;}
        PegPoint GetPointerPos(void)
        {
            return mLastPointerPos;
        }
        PEGUBYTE GetPointerType(void);
       #endif

        PegBitmap *GetSurfaceBitmap(PEGINT Surface);
        PegBitmap *GetSurfaceBitmapAndClose(PEGINT Surface);

        PEGINT GetXPointerOffset(void) {return mCurXOffset;}
        PEGINT GetXRes(void) {return mHRes;}
        PEGINT GetYPointerOffset(void) {return mCurYOffset;}
        PEGINT GetYRes(void) {return mVRes;}

        virtual DrawSurface *HideSurface(PEGINT Surface);

        virtual void InitHardwareSurface(PEGINT Width, PEGINT Height,
            DrawSurface *pSurface, PEGINT HardLayer);

       #if defined(PEG_MOUSE_SUPPORT)
        virtual void InitMousePointers();
       #endif

       #if defined(PEG_PRINTER_SUPPORT)
        PEGBOOL IsPrinting(void) const { return mPrinting; }
        void IsPrinting(PEGBOOL Printing) { mPrinting = Printing; }
       #endif

        virtual void Line(PEGINT XStart, PEGINT YStart,
                          PEGINT XEnd, PEGINT YEnd, PegBrush &Brush);

       #ifdef PEG_VECTOR_FONTS
        virtual PegFont *MakeFont(PegFont *pSourceFont, PEGUBYTE Height,
                                  PEGBOOL Bold = FALSE, PEGBOOL Italic = FALSE,
                                  PEGINT ForceWidth = 0);
       #endif

       virtual PEGULONG NumColors(void) {return mNumColors;}

       #ifdef PEG_PLOTPOINTVIEW_AS_FUNCTION
        virtual void PlotPointView(PEGINT x, PEGINT y, PEGCOLOR c) = 0;
       #endif

        virtual void PlotSubPixel(PegFixed xVal, PegFixed yVal,
            PEGCOLOR Color) = 0;


        virtual void Polygon(PegPoint *pPoints,
                             PEGUINT NumPoints, PegBrush &Brush);

        virtual void PolyLine(PegPoint *pPoints,
                              PEGUINT NumPoints, PegBrush &Brush);

       #ifdef PEG_IMAGE_SCALING
        virtual void PutBitmapPixel(PEGINT x, PEGINT y, PegBitmap *pMap,
                                    PEGCOLOR c) = 0;
       #endif

        virtual void  PutPixel(PEGINT x, PEGINT y,
                               PEGCOLOR Color);

        virtual void Rectangle(const PegRect &Rect, PegBrush &Brush);

        void RectangleXOR(const PegRect &InRect);

       #ifdef PEG_OPERA
        void RectangleXORFill(const PegRect &InRect);
       #endif

        virtual PEGBOOL RectMove(PegRect Get, PegRect ClipTo,
                                 PEGINT xShift, PEGINT yShift);

       #if defined(PEG_OPENGL_SINGLE_SURFACE)
        virtual void RefreshCompositeSurface(void) = 0;
       #endif // PEG_OPENGL_SINGLE_SURFACE

       #if defined(PEG_OPENGL_MULTIPLE_SURFACES)
        virtual void RefreshScreens(void) = 0;
       #endif // PEG_OPENGL_MULTIPLE_SURFACES

       #ifdef PEG_BITSTREAM
        #if (PEG_NUM_COLORS >= 256)
        void RenderAliasedText(PegBitstream *pBitstream, PegPoint Where,
                        const PEGCHAR *Text, PegBrush &Brush, PEGINT iCount = -1);
        #endif // PEG_NUM_COLORS >= 256

        void RenderText(PegBitstream *pBitstream, PegPoint Where,
                        const PEGCHAR *Text, PegBrush &Brush, PEGINT iCount = -1);
       #endif // PEG_BITSTREAM

        virtual void ResetPalette(void) = 0;

       #ifdef PEG_IMAGE_SCALING
        virtual PegBitmap *ResizeImage(PegBitmap *pSrc, PEGINT Width,
                                       PEGINT Height);
       #endif

        virtual void Restore(PegCapture *Info);

        virtual void SetPalette(PEGINT First, PEGINT Num,
                                const PEGUBYTE *pGet) = 0;

        virtual void SetPowerSaveMode(PEGINT Mode) {Mode = Mode;}

       #if defined(PEG_MOUSE_SUPPORT)
        virtual void SetPointerPos(PegPoint);
        virtual void SetPointerType(PEGUINT Type);
       #endif

        virtual void SetSurfaceAlpha(PEGINT Surface, PEGINT Alpha);

        void SetSurfaceDisplayOffset(PEGINT Surface,
            PEGINT xOffset, PEGINT yOffset);

        void SetSurfaceDrawOffset(PEGINT Surface,
            PEGINT xOffset, PEGINT yOffset);

        void SetSurfaceOffset(PEGINT Surface, PEGINT xOffset,
            PEGINT yOffset);

        virtual void SetSurfaceSize(PEGINT Surface, PEGINT xSize, PEGINT ySize,
            PEGINT xOffset, PEGINT yOffset);

       #if defined(PEG_MOUSE_SUPPORT)
        virtual void ShowPointer(PEGBOOL Show);
       #endif

        virtual DrawSurface *ShowSurface(PEGINT Surface);

       #if defined(PEG_IMAGE_SCALING) && defined(PEG_OPERA)
        virtual void StretchBitmap(PEGINT yr,PEGINT yw, const PegBitmap *pSrc,
                                   const PegRect &pDest,
                                   const PegRect View) = 0;
        virtual void StretchRLEBitmap(const PegBitmap *pSrc,
                                      const PegRect &pDest,
                                      const PegRect View) = 0;
       #endif

        void SurfaceToFront(PEGINT Surface);


        PEGINT TextHeight(PEGINT FontId);

        virtual PEGINT TextHeight(const PegFont *pFont);

        PEGINT TextWidth(const PEGCHAR *pText, PEGINT FontId, PEGINT Len = -1);

        virtual PEGINT TextWidth(const PEGCHAR *pText, const PegFont *pFont,
                                 PEGINT Len = -1);

       #ifdef PEG_BUILD_PRESS
        friend class PegRemoteScreenServer;
       #endif

    protected:

       #ifdef PEG_AA_LINE

        virtual void AALine(PEGINT XStart, PEGINT YStart,
                            PEGINT XEnd, PEGINT YEnd, PegBrush &Brush);

        virtual void AALineView(PEGINT xStart, PEGINT yStart, PEGINT xEnd,
                                PEGINT yEnd, const PegRect &View,
                                PegBrush &Brush) = 0;
       #endif


       #if defined(PEG_ARC_GRAPHICS)
        virtual void ArcLine(PEGINT xs, PEGINT ys, PEGINT xe, PEGINT ye,
                             PegRect &View);
        virtual void ArcFill(PEGINT xCen, PEGINT yCen, PEGINT XRadius,
                             PEGINT YRadius, PEGINT StartAngle,
                             PEGINT EndAngle, PegBrush &Brush, PegRect &View);
        virtual void ArcToView(PEGINT xCen, PEGINT yCen, PEGINT XRadius,
                               PEGINT YRadius, PEGINT StartAngle,
                               PEGINT EndAngle, PegBrush &Brush,
                               PegRect &View);
        virtual void ArcToViewSpecial(PEGINT xCen, PEGINT yCen, PEGINT XRadius,
                               PEGINT YRadius, PEGINT StartAngle,
                               PEGINT EndAngle, PegBrush &Brush,
                               PegRect &View);

        void CalcEllipsePoint(PEGINT Angle, PEGINT asq, PEGINT bsq,
                              PEGINT &X, PEGINT &Y);
       #endif

       #if defined(PEG_OPERA) && defined(PEG_IMAGE_SCALING)
        virtual void BitmapScaleView(const PegRect View, const PegBitmap *pMap,
                                     const PegRect &pDest) = 0;
       #endif

        virtual void BitmapView(const PegPoint Where, const PegBitmap *pMap,
                                const PegRect &View) = 0;

        virtual void BoxLine(PEGINT xs, PEGINT ys, PEGINT xe, PEGINT ye,
            PegBrush &Brush);

        void BoxLineView(const PegRect &LimitRect, PegFixedPoint *pPoints,
            PegBrush &Brush);

       #ifdef PEG_ARC_GRAPHICS
        virtual void ChordFill(PEGINT xCen, PEGINT yCen, PEGINT XRadius,
                               PEGINT YRadius, PEGINT StartAngle,
                               PEGINT EndAngle, PegBrush &Brush,
                               PegRect &View);
        virtual void ChordFillSpecial(PEGINT xCen, PEGINT yCen, PEGINT XRadius,
                                      PEGINT YRadius, PEGINT StartAngle,
                                      PEGINT EndAngle, PegBrush &Brush,
                                      PegRect &View);

       #endif /* end of PEG_ARC_GRAPHICS */

       #ifdef PEG_ARC_GRAPHICS
        virtual void Circle(const PegRect &LimitRect, PEGINT xCenter,
                            PEGINT yCenter, PEGINT Radius, PegBrush &Brush);

        virtual void CircleFast(PEGINT xCenter, PEGINT yCenter, PEGINT Radius,
                            PegBrush &Brush);
       #endif

       #ifdef PEG_PRO
        virtual void DrawAliasMapView(PegPoint Where, const PegBitmap *pMap,
            PegBrush &Brush, const PegRect &View) = 0;
       #endif


        virtual void DrawTextView(PegPoint Put, const PEGCHAR *Text,
                                  PegBrush &Brush, const PegFont *pFont,
                                  PEGINT Len, PegRect &View) = 0;

       #ifdef PEG_ARC_GRAPHICS
        virtual void EllipseFast(const PegRect &Bound, PegBrush &Brush);

        virtual void EllipseToView(const PegRect &Bound, PegBrush &Brush,
            PegRect View);

       #endif

       #if defined(PEG_SOFTWARE_CURSOR)
        virtual PEGBOOL EnterMouseContext(const PegRect &Invalid);
        virtual void ExitMouseContext(void) {EndDraw();}
       #endif

        void FastWideHLine(PEGINT xStart, PEGINT xEnd, PEGINT YVal,
            PEGINT Width, PEGCOLOR LineColor);

        void FastWideVLine(PEGINT yStart, PEGINT yEnd, PEGINT xVal,
            PEGINT Width, PEGCOLOR LineColor);

       #ifdef PEG_ARC_GRAPHICS
        virtual void FillCircle(const PegRect &LimitRect, PEGINT xCenter,
                                PEGINT yCenter, PEGINT r, PEGCOLOR FillColor);
        virtual void FillCircleFast(PEGINT xCenter, PEGINT yCenter,
                                    PEGINT r, PEGCOLOR FillColor);

       #endif

        virtual void FillPolygon(PegRect &Bound,
                                 PegPoint *pPoints, PEGINT NumPoints,
                                 PEGCOLOR Color);
        virtual void FillPolygonView(const PegRect &View, PegPoint *pPoints,
                                     PEGINT NumPoints, PEGCOLOR Color);

        virtual PEGCOLOR GetPixelView(PEGINT x, PEGINT y) = 0;

       #if defined(PEG_MOUSE_SUPPORT)
        virtual void HidePointer(void);
       #endif

        virtual void HorizontalLine(PEGINT xStart, PEGINT xEnd,
                                    PEGINT y, PEGCOLOR Color,
                                    PEGINT Width) = 0;
        virtual void HorizontalLineXOR(PEGINT xs, PEGINT xe, PEGINT y) = 0;

       #if defined(PEG_VID_MEM_MANAGER)
        virtual void InitVidMemManager(PEGUBYTE *pStart, PEGUBYTE *pEnd);
       #endif

        virtual void LineView(PEGINT xStart, PEGINT yStart,
                              PEGINT xEnd, PEGINT yEnd,  PegRect &View,
                              PegBrush &Brush) = 0;

        virtual void MemoryToScreen(void) = 0;

       #ifdef PEG_ARC_GRAPHICS
        virtual void OutlineCircle(const PegRect &LimitRect, PEGINT xCenter,
                                   PEGINT yCenter, PEGINT r, PEGCOLOR Color,
                                   PEGINT Width);

        virtual void OutlineCircleFast(PEGINT xCenter, PEGINT yCenter,
                                       PEGINT r, PEGCOLOR Color, PEGINT Width);

       #endif

        virtual void PatternFillPolygon(PegRect &Bound,
                                PegPoint *pPoints, PEGINT NumPoints,
                                PegBrush &Brush);

        virtual void PatternFillPolygonView(const PegRect &View,
                                            PegPoint *pPoints,
                                            PEGINT NumPoints, PegBrush &Brush);

        virtual void PatternLine(PEGINT XStart,
                                 PEGINT YStart, PEGINT XEnd, PEGINT YEnd,
                                 PegBrush &Brush);

        virtual void PatternLineView(PEGINT XStart, PEGINT YStart, PEGINT XEnd,
                                 PEGINT YEnd, PegRect &Rect,
                                 PegBrush &Brush);

       #ifdef PEG_ARC_GRAPHICS
        virtual void PlotEllipsePoints(PegRect &Bound);
       #endif

        void PrepareBrush(PegBrush &Brush);

        virtual void RectangleView(const PegRect &InRect, PegRect &View,
                               PegBrush &Brush);

       #ifdef PEG_OPERA
        virtual void RectangleXORView(const PegRect &View) = 0;
       #endif

        virtual void RectMoveView(const PegRect &View,
                                  const PEGINT xMove, const PEGINT yMove) = 0;

      #ifdef PEG_BITSTREAM
       #if (PEG_NUM_COLORS >= 256)
        void RenderAliasedTextView(PegBitstream *pBitstream, PegPoint Where,
                                   PegRect View, const PEGUSHORT *pText,
                                   PegBrush &Brush, PEGINT NumChars,
                                   PEGSHORT *pKernData);
       #endif // PEG_NUM_COLORS >= 256

        void RenderTextView(PegBitstream *pBitstream, PegPoint Where,
                            PegRect View, const PEGUSHORT *pText,
                            PegBrush &Brush, PEGINT NumChars,
                            PEGSHORT *pKernData);
      #endif

        virtual void SetSurfaceDisplayOffset(DrawSurface *pSurface,
            PEGINT xOffset, PEGINT yOffset);

        virtual void SetSurfaceDrawOffset(DrawSurface *pSurface,
            PEGINT xOffset, PEGINT yOffset);

        virtual void SetSurfaceOffset(DrawSurface *pSurface,
            PEGINT xOffset, PEGINT yOffset);

        void SetSurfaceView(DrawSurface *pSurface);

        virtual void VerticalLine(PEGINT yStart, PEGINT yEnd,
                                  PEGINT x, PEGCOLOR Color, PEGINT Width) = 0;
        virtual void VerticalLineXOR(PEGINT ys, PEGINT ye, PEGINT x) = 0;

       #if defined(PEG_MOUSE_SUPPORT)
        PegPoint mLastPointerPos;

        PegPointer mpPointers[NUM_POINTER_TYPES];
        PegBitmap *mpCurPointer;

        #if defined(PEG_CURSOR_LAYER)
        PEGINT mMouseSurface;
        #endif

        #if defined(PEG_SOFTWARE_CURSOR)
        PegCapture mCapture;
        Viewport *mpMouseView;
        #endif
       #endif

       #if defined(PEG_VID_MEM_MANAGER)
        PEG_HEAP_CONTROL mVidHeap;
       #endif

        DrawContext *mpContext;
        DrawSurface *mpSurfaceList;

        PEGULONG mNumColors;
        PEGUINT mDrawNesting;
        PEGINT mHRes;
        PEGINT mVRes;
        PEGINT mCurXOffset;
        PEGINT mCurYOffset;
        PEGINT mOrientation;        // 0 = native, 1 = CW, 2 = CCW

       #if defined(PEG_MOUSE_SUPPORT)
        PEGBOOL mShowPointer;
        PEGBOOL mPointerHidden;
       #endif


       #if defined(PEG_PRINTER_SUPPORT)
        PEGBOOL mPrinting;
       #endif

       #if defined(PEG_OPENGL_SINGLE_SURFACE)
        PEGINT mCompositeBuffer_HRes;
        PEGINT mCompositeBuffer_VRes;
       #endif // PEG_OPENGL_SINGLE_SURFACE

    private:

        DrawContext *mpContextStack;

       #ifdef PEG_IMAGE_SCALING
        void RectStretch(PEGINT xs2,PEGINT ys2,
                         PEGINT xd2,PEGINT yd2, PegBitmap *pSrc,
                         PegBitmap *pDest);
        void Stretch(PEGINT x2, PEGINT y2,
                     PEGINT yr,PEGINT yw, PegBitmap *pSrc, PegBitmap *pDest);
       #endif


       #if defined(PEG_ARC_GRAPHICS)
        PEGINT mArcMinRow;
        PEGINT mArcMaxRow;
        PEGINT *mpCoord;
       #endif
};


/*--------------------------------------------------------------------------*/
// Prototype for CreatePegScreen()-
//
// The actual implementation is in each individual derived PegScreen class.
/*--------------------------------------------------------------------------*/
PegScreen *CreatePegScreen(const PegRect &Size);



#endif

// End of file





